//
//  MainTabBarController.m
//  iosapp
//
//  Created by 吴彬 on 15/12/11.
//  Copyright © 2015年 吴彬. All rights reserved.
//

#import "MainTabBarController.h"

#import "Test1Controller.h"
#import "Test2Controller.h"
#import "Test3Controller.h"
#import "Test4Controller.h"

@interface MainTabBarController ()<UITabBarControllerDelegate>
{
    Test1Controller *t0;
    Test2Controller *t1;
    Test3Controller *t2;
    Test4Controller *t3;
    
}
@end

@implementation MainTabBarController


- (void)viewDidLoad {
    [super viewDidLoad];
    //设置tabbar不覆盖viewcontroller下面部分
    self.tabBar.translucent = YES;
    
    self.delegate = self;
    //加载viewcontroller
    t0 = [Test1Controller new];
    t1 = [Test2Controller new];
    t2 = [Test3Controller new];
    t3 = [Test4Controller new];
    UINavigationController *tab0 = [[UINavigationController alloc] initWithRootViewController:t0];
    UINavigationController *tab1 = [[UINavigationController alloc] initWithRootViewController:t1];
    UINavigationController *tab2 = [[UINavigationController alloc] initWithRootViewController:t2];
    UINavigationController *tab3 = [[UINavigationController alloc] initWithRootViewController:t3];
    self.viewControllers = @[ tab0,
                              tab1,
                              tab2,
                              tab3
                             ];
    
    NSArray *titles = @[@"0", @"1", @"2", @"3"];
    NSArray *images = @[@"tabbar_0", @"tabbar_1", @"tabbar_2", @"tabbar_3"];
    [self.tabBar.items enumerateObjectsUsingBlock:^(UITabBarItem *item, NSUInteger idx, BOOL *stop) {
        [item setTitle:titles[idx]];
        [item setImage:[[UIImage imageNamed:images[idx]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
     
        [item setSelectedImage:[[UIImage imageNamed:[images[idx] stringByAppendingString:@"_y"]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    }];

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
